/**
 * @FilePath     : /src/lgmg_robots/agv_navigation/agv_navigate/include/agvNavigate/opInclude/operation_peripheral.h
 * @Description  : 定义了操作外设的相关类和类型，包括操作客户端的初始化、操作的开始和结束，以及反馈回调函数等。 
 * @Author       : xiujun.yang
 * @Version      : 1.0.0
 * @LastEditors  : haibo haibo.yang@lgmgim.cn
 * @LastEditTime : 2024-12-19 16:35:24
 * @Copyright (c) 2024 by 临工智能信息科技有限公司, All Rights Reserved. 
**/
#pragma once 
#include "operation.h"
#include <agv_actions/action/peripheral.hpp>

using Peripheral = agv_actions::action::Peripheral;
using GoalHandlePeripheral = rclcpp_action::ClientGoalHandle<Peripheral>;

// typedef actionlib::SimpleActionClient<ACTION_TYPE> ACTION_CLIENT_TYPE;
#define   ACTION_PICK   "pick"
#define   ACTION_DROP   "drop"

class OpClient
{
 public:
    static void InitAcitonClient(rclcpp::Node::SharedPtr node);
    static rclcpp_action::Client<Peripheral>::SharedPtr client_;
};

enum class AMR_ACTION_TYPE {
    NO_OP,
    UP,
    DOWN,
    CLOCKWISE_ROTATION,
    ANTICLOCKWISE_ROTAION,
    UP_CLOCKWISE_ROTATION,
    UP_ANTICLOCKWISE_ROTAION,
    CLOCKWISE_ROTATION_DOWN,
    ANTICLOCKWISE_ROTAION_DOWN,
};


//////////////////////////////////////////////////////////////////////////////
//   The interface of class "Operation".
class OperationPeripheral : public Operation
{
 public:
    explicit OperationPeripheral(const agv_msgs::msg::Action &action);

    // The destructor
    virtual ~OperationPeripheral();

    // Initialize the related data
    virtual bool Init() override;

    // Ready to start new op
    virtual bool ReadyStart() override;

    // Defines how to start the operation
    virtual bool StartAction() override;

    // Defines how to end the operation
    virtual bool EndAction() override;

    // Defines how to do the operation
    virtual bool Work() override;

    // for perial call back function
    void FeedbackCb(GoalHandlePeripheral::SharedPtr,
      const std::shared_ptr<const Peripheral::Feedback> feedback);

    // for perial down call back function
    void DoneCb(const GoalHandlePeripheral::WrappedResult & result);

    // for perial active call back function
    void ActiveCb(GoalHandlePeripheral::SharedPtr goal_handle);
};
